package kpg

import (
	"github.com/dgrijalva/jwt-go"
	"time"
)

const (
	APP_KEY = "www.topgoer.com"
)

func TokenHandler(userid int) string {

	token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{
		"user": userid,
		"exp":  time.Now().Add(time.Hour * time.Duration(1)).Unix(),
		"iat":  time.Now().Unix(),
	})
	tokenString, err := token.SignedString([]byte(APP_KEY))
	if err != nil {
		panic(err)
	}
	return tokenString
}
